﻿using System;
using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;

public class SearchFriendRequest : BaseRequest
{
	private SearchFriendPanel _searchFriendPanel;
	
	
	protected override void Awake()
	{
		_controllerType = ControllerType.USER;
		_methodType = MethodType.SEARCH_FRIEND;
		base.Awake();
	}

	// Use this for initialization
	void Start () {
		//组件初始化
		_searchFriendPanel = this.gameObject.GetComponent<SearchFriendPanel>();
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	public void SendRequest(String nick)
	{
		JsonData jsonData =new JsonData();
		jsonData["nick"] = nick;
		NettyRequest nettyRequest = new NettyRequest();
		nettyRequest.controllerType = (int) _controllerType;
		nettyRequest.methodType = (int) _methodType;
		nettyRequest.data =JsonMapper.ToJson(jsonData);
		byte[] dataBytes = ConverterTool.SerialRequestObj(nettyRequest);
		UnityFacade.Instance.ClientManager.SendMsgToServer(dataBytes);

	}
	
	
	public override void OnResponse(string data)
	{
		_searchFriendPanel.HandleSearchFriendResponse(data);
	}

	
	
	
	
	
}
